package com.huangmb.anymark.app.app;

import android.app.Application;
import com.huangmb.anymark.app.model.UserContext;
import com.qiniu.android.common.Zone;
import com.qiniu.android.storage.Configuration;
import com.qiniu.android.storage.UploadManager;

/**
 * @author hmb
 * @version 1.0
 * @since 2016/4/14 21:04
 */
public class AnyMarkApplication extends Application {
    private static AnyMarkApplication instance = null;
    private UserContext mUserContext = null;
    private UploadManager mUploadManager;
    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        Configuration config = new Configuration.Builder()
                .chunkSize(256 * 1024)  //分片上传时，每片的大小。 默认 256K
                .putThreshhold(512 * 1024)  // 启用分片上传阀值。默认 512K
                .connectTimeout(10) // 链接超时。默认 10秒
                .responseTimeout(60) // 服务器响应超时。默认 60秒
                //.recorder(recorder)  // recorder 分片上传时，已上传片记录器。默认 null
                //.recorder(recorder, keyGen)  // keyGen 分片上传时，生成标识符，用于片记录器区分是那个文件的上传记录
                .zone(Zone.zone0) // 设置区域，指定不同区域的上传域名、备用域名、备用IP。默认 Zone.zone0
                .build();
        mUploadManager = new UploadManager(config);
    }

    public static AnyMarkApplication getInstance(){
        return instance;
    }

    /**
     * 获取七牛云存储的上传管理器
     * @return 上传管理器
     */
    public UploadManager getUploadManager(){
        return mUploadManager;
    }
    public UserContext getUserContext(){
        return mUserContext;
    }
    public void setUserContext(UserContext context){
        mUserContext = context;
    }
}
